#ifndef BENCHMARK_H
#define BENCHMARK_H

/* Includes */
#include "genlib.h"
#include <time.h>
#include "utils.h"

/* Struct containing data for a single benchmark test */
typedef struct {
	char *name;
	double start;
	double end;
	double elapsed;
	int numCritOp;
} *benchmarkT;

/* Global benchmark struct */
benchmarkT benchmark;

/* Function: benchAddOperation
 * Usage: if (benchAddOperation(benchmarkT benchmark)) ...
 * ---
 * Increments field numCritOp within the provided benchmarkT struct by one.
 * Returns TRUE if succeeded, otherwise FALSE
 */
bool benchAddOperation(benchmarkT b);

/* Function: benchmarkStart
 * Usage: benchmarkStart("Insertion sort", benchmarkT b);
 * ---
 * Starts the benchmarking. Should be called right before
 * execution of the critical function/code that's being tested
 */
void benchmarkStart(char *name, benchmarkT b);

/* Function: benchmarkEnd
 * Usage: benchmarkEnd(benchmarkT b);
 * ---
 * Ends the benchmarking. Should be called after the
 * time critical function/code has finished
 */
void benchmarkEnd(benchmarkT b);

/* Procedure: saveBenchToFile
 * Usage: saveBenchToFile(benchmarkT b, numRecords, arrayType, avgCritOp, avgTime);
 * ---
 * Saves the calculated benchmark information in a specific 
 * textfile for each sort algorithm
 */
void saveBenchToFile(algorithmT alg, int numRecords, int arrayType, int avgCritOp, double avgTime);

/* Procedure: printBenchmark
 * Usage: printBenchmark();
 * ---
 * Prints information from the current, global, benchmarkT struct
 */
void printBenchmark(void);

#endif